<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet  [
<!ENTITY nbsp   "&#160;">
<!ENTITY agrave "&#224;">
<!ENTITY egrave "&#232;">
<!ENTITY eacute "&#233;">
<!ENTITY ocirc	"&#244;">
<!ENTITY copy   "&#169;">
<!ENTITY reg    "&#174;">
<!ENTITY trade  "&#8482;">
<!ENTITY mdash  "&#8212;">
<!ENTITY ldquo  "&#8220;">
<!ENTITY rdquo  "&#8221;"> 
<!ENTITY pound  "&#163;">
<!ENTITY yen    "&#165;">
<!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="babel-transform-schema.xsd"
    xmlns:bw="http://tice2.univ-reunion.fr/babelweb" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"
    version="1.0">
    
    <xsl:import href="../manifest-manager.xsl"/>
    
    <xsl:param name="training">
        <xsl:choose>
            <xsl:when test="//assessmentItem/@lang='fr'">Entraînement</xsl:when>
            <xsl:when test="//assessmentItem/@lang='it'">Pratica</xsl:when>
            <xsl:when test="//assessmentItem/@lang='es'">Entrenamiento</xsl:when>
            <xsl:otherwise>Language error [code6a]</xsl:otherwise>
            </xsl:choose>
    </xsl:param>
    <xsl:param name="discovery">
        <xsl:choose>
            <xsl:when test="//assessmentItem/@lang='fr'">Découverte</xsl:when>
            <xsl:when test="//assessmentItem/@lang='it'">Scoperta</xsl:when>
            <xsl:when test="//assessmentItem/@lang='es'">Explora</xsl:when>
            <xsl:otherwise>Language error  [code6b]</xsl:otherwise>
            </xsl:choose>
    </xsl:param>
    <xsl:param name="information">
        <xsl:choose>
            <xsl:when test="//assessmentItem/@lang='fr'">Information</xsl:when>
            <xsl:when test="//assessmentItem/@lang='it'">Informazione</xsl:when>
            <xsl:when test="//assessmentItem/@lang='es'">Información</xsl:when>
            <xsl:otherwise>Language error  [code6c]</xsl:otherwise>
            </xsl:choose>
    </xsl:param>
    <xsl:param name="previous">
        <xsl:choose>
            <xsl:when test="//assessmentItem/@lang='fr'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:when>
            <xsl:when test="//assessmentItem/@lang='it'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:when>
            <xsl:when test="//assessmentItem/@lang='es'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:when>
            <xsl:otherwise>Language error  [code6d]</xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <xsl:param name="next">
        <xsl:choose>
            <xsl:when test="//assessmentItem/@lang='fr'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:when>
            <xsl:when test="//assessmentItem/@lang='it'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:when>
            <xsl:when test="//assessmentItem/@lang='es'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:when>
            <xsl:otherwise>Language error  [code6e]</xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <!--<xsl:param name="previous">
        <xsl:choose>
            <xsl:when test="//assessmentItem/@lang='fr'">Précédent</xsl:when>
            <xsl:when test="//assessmentItem/@lang='it'">Precedente</xsl:when>
            <xsl:when test="//assessmentItem/@lang='es'">Anterior</xsl:when>
            <xsl:otherwise>Language error  [code6d]</xsl:otherwise>
            </xsl:choose>
    </xsl:param>
    <xsl:param name="next">
        <xsl:choose>
            <xsl:when test="//assessmentItem/@lang='fr'">Suivant</xsl:when>
            <xsl:when test="//assessmentItem/@lang='it'">Successivo</xsl:when>
            <xsl:when test="//assessmentItem/@lang='es'">Siguiente</xsl:when>
            <xsl:otherwise>Language error  [code6e]</xsl:otherwise>
        </xsl:choose>
    </xsl:param>-->
    <xsl:param name="youwant">
        <xsl:choose>
            <xsl:when test="//assessmentItem/@lang='es'"></xsl:when>
            <xsl:when test="//assessmentItem/@lang='fr'"></xsl:when>
            <xsl:when test="//assessmentItem/@lang='it'"></xsl:when>
            <xsl:otherwise>Language error [code6f]</xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <!--<xsl:param name="youwant">
        <xsl:choose>
            <xsl:when test="//assessmentItem/@lang='es'">Que desea...</xsl:when>
            <xsl:when test="//assessmentItem/@lang='fr'">Vous voulez...</xsl:when>
            <xsl:when test="//assessmentItem/@lang='it'">Per...</xsl:when>
            <xsl:otherwise>Language error [code6f]</xsl:otherwise>
        </xsl:choose>
    </xsl:param>-->
    <xsl:param name="home">
        <xsl:choose>
            <xsl:when test="//assessmentItem/@lang='es'">Página de acogida</xsl:when>
            <xsl:when test="//assessmentItem/@lang='fr'">Accueil</xsl:when>
            <xsl:when test="//assessmentItem/@lang='it'">Home</xsl:when>
            <xsl:otherwise>Language error [code6g]</xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    
    
    <!--<xsl:template match="/">
        <xsl:for-each select="babelweb-data">
            <xsl:call-template name="get-manifest">
                <xsl:with-param name="lang" select="//assessmentItem/@lang"/>
                <xsl:with-param name="module" select="//assessmentItem/@module"/>
            </xsl:call-template>
        </xsl:for-each>
    </xsl:template>-->
    
    <xsl:template name="page-navigation">
        <xsl:param name="class" select="''"/>
       <!-- <xsl:call-template name="get-manifest">
            <xsl:with-param name="lang" select="//assessmentItem/@lang"/>
            <xsl:with-param name="module" select="//assessmentItem/@module"/>
        </xsl:call-template>-->
        <div class="page-navigation {$class}">
            <ul>
                <xsl:call-template name="page-nav-engine"/>
            </ul>
        </div>
        <br/>
    </xsl:template>
    
    <xsl:template name="page-navigation-fil">
        <div class="page-navigation">
            <ul id="babel-nav">
                <li class="ariane">
                    <div>
                   <xsl:choose>
                       <xsl:when test="//assessmentItem/@identifier='intro_f'"> 
                                > <img src="/babel-data/images/assets/home.gif" alt="home"/>
                           <xsl:value-of select="$youwant"/>  <xsl:value-of select="$home"/>
                       
                       </xsl:when>
                       
                       <xsl:when test="//assessmentItem/@identifier='intro_i'"> 
                           > <img src="/babel-data/images/assets/home.gif" alt="home"/>
                           <xsl:value-of select="$youwant"/>  <xsl:value-of select="$home"/>
                       </xsl:when>
                       
                       <xsl:when test="//assessmentItem/@identifier='intro_e'"> 
                           > <img src="/babel-data/images/assets/home.gif" alt="home"/>
                           <xsl:value-of select="$youwant"/>  <xsl:value-of select="$home"/>
                       </xsl:when>
                       
                       <xsl:otherwise>
                                <a href="index.php/{//pool[@name='Accueil']/subpool/resource[1]/@href}" alt="HOME">
                                    <img src="/babel-data/images/assets/home.gif" alt="home"/>
                                    <xsl:value-of select="$youwant"/>
                                    </a>
                       </xsl:otherwise>
                   </xsl:choose>
                    </div>
                </li>
                <xsl:if test="not(starts-with(//assessmentItem/@identifier,'intro'))">
                    <li class="ariane">
                        <div>
                            <xsl:value-of
                                select="//resource[@identifier=//assessmentItem/@identifier]/ancestor::pool/@name"/>
                        </div></li>
                    <xsl:call-template name="page-nav-engine"/>
                </xsl:if>
<!--                call other list items : discovery, training, next page etc-->
                
            </ul>
        </div>
<!--        <br/>-->
    </xsl:template>
    
    <xsl:template name="page-nav-engine">
<!--        <xsl:if test="not(starts-with(//assessmentItem/@identifier,'intro'))">-->
        
            <li>
                <xsl:call-template name="apply-prev">
                    <xsl:with-param name="node"
                        select="//resource[@identifier=//assessmentItem/@identifier]"/>
                </xsl:call-template>
            </li>
            <xsl:apply-templates select="//pool"/>
            <li>
                <xsl:call-template name="apply-next">
                    <xsl:with-param name="node"
                        select="//resource[@identifier=//assessmentItem/@identifier]"/>
                </xsl:call-template>
            </li>
        <!--</xsl:if>-->
    </xsl:template>
    
    <xsl:template match="pool">
        <xsl:choose>
            <xsl:when test="descendant::resource/@identifier='Accueil'">
               <!-- <xsl:variable name="addedClass"><xsl:text>notCurrentPool</xsl:text></xsl:variable>
                <li class="{$addedClass}">
                    <a href="{descendant::resource[1]/@href}"><xsl:value-of select="@name"/></a>
                </li>-->
            </xsl:when>
            <xsl:when test="descendant::node()/@identifier = //assessmentItem/@identifier">
                <xsl:variable name="addedClass"><xsl:text>currentPool</xsl:text></xsl:variable>
                <li class="{$addedClass}">
                    <ul id="{@name}">
                        <xsl:apply-templates select="subpool" mode="minimal"/>
                    </ul>
                </li>
            </xsl:when>
            <xsl:otherwise>
               <!-- <xsl:variable name="addedClass"><xsl:text>notCurrentPool</xsl:text></xsl:variable>
                <li class="{$addedClass}">
                    <a href="{descendant::resource[1]/@href}"><xsl:value-of select="@name"/></a>
                </li>-->
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="subpool" mode="maximal">
        <li class="{@type}">
            <ul><xsl:apply-templates select="resource"/></ul>
        </li>
    </xsl:template>
    
    <xsl:template match="subpool" mode="minimal">
        <xsl:choose>
            <xsl:when test="descendant::resource/@identifier = //assessmentItem/@identifier">
                <xsl:variable name="addedClass">
                    <xsl:text>currentSubPool</xsl:text>
                </xsl:variable>
                <li class="{@type} {$addedClass}">
                    <xsl:choose>
                        <xsl:when test="@type='training'">
                            <a href="index.php/{resource[1]/@href}" alt="Vous êtes à l'entraînement">
                                <xsl:value-of select='$training'/> </a>
                        </xsl:when>
                        <xsl:when test="@type='discovery'">
                            <a href="index.php/{resource[1]/@href}" alt="Vous êtes à la découverte">
                                <xsl:value-of select='$discovery'/> </a>
                        </xsl:when>
                        <xsl:when test="@type='information'">
                            <a href="index.php/{resource[1]/@href}" alt="Vous consultez les information">
                                <xsl:value-of select='$information'/> </a>
                        </xsl:when>
                    </xsl:choose>
                </li>
            </xsl:when>

            <xsl:otherwise>
                <li class="{@type} notCurrentSubPool">
                    <xsl:choose>
                        <xsl:when test="@type='training'">
                            <a href="index.php/{resource[1]/@href}" alt="Training">
                                <xsl:value-of select="$training"/>
                            </a>
                        </xsl:when>
                        <xsl:when test="@type='discovery'">
                            <a href="index.php/{resource[1]/@href}" alt="Discovery">
                                <xsl:value-of select="$discovery"/>
                            </a>
                        </xsl:when>
                        <xsl:when test="@type='information'">
                            <a href="index.php/{resource[1]/@href}" alt="Information">
                                <xsl:value-of select="$information"/>
                            </a>
                        </xsl:when>
                    </xsl:choose>
                </li>

            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="resource">
        <xsl:choose>
            <xsl:when test="@identifier = //assessmentItem/@identifier">
                <xsl:variable name="addedClass"><xsl:text>currentSubPool</xsl:text></xsl:variable>
                <li class="{$addedClass}">
                    <a id="{@identifier}" href="index.php/{@href}">
                        <xsl:value-of select="@identifier"/>
                    </a>
                </li>
            </xsl:when>
            <xsl:otherwise>
                <li>
                    <a id="{@identifier}" href="index.php/{@href}">
                        <xsl:value-of select="@identifier"/>
                    </a>
                </li>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template name="apply-prev">
        <xsl:param name="node"/>
        <xsl:for-each select="$node">
            <xsl:choose>
                <xsl:when test="not(preceding-sibling::resource) and not(parent::node()/preceding-sibling::subpool[1])">
                    <div class="page-prev">
                        <a href="index.php/{//pool[@name='Accueil']/subpool/resource[1]/@href}">
                            <xsl:value-of select='$previous'/>
                        </a>
                    </div>
                </xsl:when>
                <xsl:when test="preceding-sibling::resource[1]">
                    <div class="page-prev">
                        <a href="index.php/{preceding-sibling::resource[1]/@href}">
                            <xsl:value-of select='$previous'/>
                        </a>
                    </div>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:choose>
                        <xsl:when test="parent::node()/preceding-sibling::subpool[1]">
                            <div class="page-prev">
                                <a href="index.php/{preceding::resource[1]/@href}"> <xsl:value-of select='$previous'/>
                                </a>
                            </div>
                        </xsl:when>
                    </xsl:choose>
                </xsl:otherwise>
                
            </xsl:choose>
        </xsl:for-each>
    </xsl:template>
    
    <xsl:template name="apply-next">
        <xsl:param name="node"/>
        <xsl:for-each select="$node">
            <xsl:choose>
                <xsl:when test="following-sibling::resource[1]">
                    <div class="page-next">
                        <a href="index.php/{following-sibling::resource[1]/@href}">
                            <xsl:value-of select='$next'/>
                        </a>
                    </div>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:choose>
                        <xsl:when test="parent::node()/following-sibling::subpool[1]">
                            <div class="page-next">
                                <a href="index.php/{following::resource[1]/@href}"> <xsl:value-of select='$next'/>
                                </a>
                            </div>
                        </xsl:when>
                        <xsl:otherwise> 
                            <div class="page-next">
                                <a href="index.php/{//pool[@name='Accueil']/subpool/resource[1]/@href}"> <xsl:value-of select='$next'/>
                                </a>
                            </div>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:otherwise>
            </xsl:choose>
            
        </xsl:for-each>
    </xsl:template>
    
</xsl:stylesheet>